*** Settings ***
Library    HttpLibrary.HTTP
Library    Collections

*** Variables ***
${BASE_URL}    127.0.0.1:10443
${LOGIN_URL}    /api/login
${PRODUCT_PAGE}    /UI/Static/#/navigate/system/info/product
${OPENUBNC_USERNAME}            Administrator
${OPENUBMC_PASSWORD}            Admin@90000

*** Test Cases ***
Test Product Page With Login
    [Documentation]    测试需要登录的产品信息页面
    # 1. 创建HTTP上下文
    Create Http Context    ${BASE_URL}    https
    Set Client Configuration    ssl_verify=False
    
    # 2. 先执行登录获取认证token
    Set Request Header    Content-Type    application/json
    ${auth_data}=    Create Dictionary    username=${OPENUBMC_USERNAME}    password=${OPENUBMC_PASSWORD}
    POST    ${LOGIN_URL}    ${auth_data}
    ${status}=    Get Response Status
    Should Be Equal As Numbers    ${status}    200
    
    # 3. 获取并设置认证token
    ${response}=    Get Response Body
    ${token}=    Get From Dictionary    ${response}    token
    Set Request Header    Authorization    Bearer ${token}
    
    # 4. 现在测试需要认证的页面
    GET    ${PRODUCT_PAGE}
    ${status}=    Get Response Status
    Should Be Equal As Numbers    ${status}    200
    ${body}=    Get Response Body
    Should Contain    ${body}    productInfo    # 根据实际响应调整